﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace InControl
{
    public partial class INV_NewItem_form : Form
    {
        public INV_NewItem_form()
        {
            InitializeComponent();
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            ((INV_MDIParent)this.MdiParent).OpenForm(typeof(INV_office_form));
        }

        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void Off_New_Panel_Paint(object sender, PaintEventArgs e)
        {

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox8_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox7_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox6_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox5_TextChanged(object sender, EventArgs e)
        {

        }

        private void label11_Click(object sender, EventArgs e)
        {

        }

        private void label10_Click(object sender, EventArgs e)
        {

        }

        private void label9_Click(object sender, EventArgs e)
        {

        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {

        }

        private void label8_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void panel3_Paint(object sender, PaintEventArgs e)
        {

        }

        private void panel4_Paint(object sender, PaintEventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void label12_Click(object sender, EventArgs e)
        {

        }

        private void textBox9_TextChanged(object sender, EventArgs e)
        {

        }

        private void combo()
        {
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            try
            {
                ((INV_MDIParent)this.MdiParent).appDriver.recordNewItem(textBox1.Text, textBox4.Text, comboBox1.Text, comboBox2.Text, comboBox3.Text, textBox6.Text);
                textBox9.Text = ((INV_MDIParent)this.MdiParent).appDriver.GetStock(textBox1.Text, comboBox1.Text, comboBox2.Text).ToString();
                //textBox9.Text = ((INV_MDIParent)this.MdiParent).appDriver.GetStock(textBox1.Text, comboBox1.Text, comboBox2.Text).ToString();
            }
            catch (SqlException ex)
            {
                if (ex.ErrorCode == -2146232060)
                {
                    //richTextBox1.Text = "ITEM EXISTS\nCODE: " + ex.ErrorCode + "\n" + ex.Message;
                    //panel1.Visible = true;
                    //MessageBox.Show("SQLERROR: " + ex.Message);
                }
            }
            
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void INV_NewItem_form_Load(object sender, EventArgs e)
        {
            ((INV_MDIParent)this.MdiParent).appDriver.FillCombo(comboBox1, "cat_table", "catergory", "id", 0);
            //((INV_MDIParent)this.MdiParent).appDriver.FillCombo(comboBox2, "type_table", "type", "id");
            //((INV_MDIParent)this.MdiParent).appDriver.FillCombo(comboBox3, "inven_table", "location", "id");
        }

        private void label13_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox4_Click(object sender, EventArgs e)
        {
            panel1.Visible = false;
        }
    }
}
